#include <stdio.h>
#include <unistd.h>


#include "ssdp.h"


int main(int argc, char *argv[])
{
    ssdp_dev_t dev = {
        "upnp:ssdp-test1",
        "upnp:ssdp-test-instance",
        "tcp:192.168.11.139:6000",
        60
    };
    
    ssdp_start_service(&dev);
    
    while (1) {
        ssdp_dev_t search_dev = {0};
        #if 1
        //int ret = ssdp_msearch("urn:schemas-upnp-org:service:WANIPConnection:1", 3, &search_dev);
        int ret = ssdp_msearch("upnp:ssdp-test", 3, &search_dev);
        if (ret > 0) {
            printf("live ssdp device:\n");
            printf("\ttype:%s\n", search_dev.srv_type);
            printf("\tname:%s\n", search_dev.srv_name);
            printf("\tlocation:%s\n", search_dev.location);
            printf("\texpiration: %d\n", search_dev.expiration);
        } 
        #endif
        sleep(5);
    }
    ssdp_stop_service();
    
    return 0;
}
